package com.example.activitytest

import android.app.Activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.Toast

class SecondActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_second)
        val button2 = findViewById<Button>(R.id.button2)

//        val dataStr = intent.getStringExtra("str")
//        val dataInt = intent.getIntExtra("int", 0)
//        button2.setOnClickListener(){
//            Toast.makeText(this, "click button 2 dataStr: $dataStr  dataInt: $dataInt", Toast.LENGTH_SHORT).show()
//        }

        button2.setOnClickListener() {
            val intent = Intent()
            intent.putExtra("my-data", "test data")
            setResult(Activity.RESULT_OK, intent)
            finish()
        }
    }
}